<?php
require_once __DIR__ . "/vendor/autoload.php";
require_once __DIR__ . "/app/config/define.php";


use Core\server\HttpServer;
use Swoole\Process;

\Swoole\Runtime::enableCoroutine(true);

try {
    if ($argc != 2) {
        throw new Exception("参数错误");
    }
    switch ($argv[1]) {
        case "start":
            $server = new HttpServer();
            $server->run();
            break;
        case "stop":
            $getPid = intval(file_get_contents("./wolf.pid"));
            if ($getPid && trim($getPid) != 0) {
                Process::kill($getPid);
            }
            break;
        default:
            throw new Exception("参数错误");
    }
} catch (Exception $exception) {
    echo "错误内容:" . $exception->getMessage() . PHP_EOL . ",错误文件:" . $exception->getLine() . ",错误行数:" . $exception->getLine();
}
